package com.htgd.gardenexpo.service.impl;

import com.htgd.gardenexpo.entity.CommonResult;
import com.htgd.gardenexpo.entity.GeConVenue;
import com.htgd.gardenexpo.dao.GeConVenueDao;
import com.htgd.gardenexpo.entity.PageQuery;
import com.htgd.gardenexpo.page.VenueQuery;
import com.htgd.gardenexpo.service.GeConVenueService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.htgd.gardenexpo.vo.VenueNumsVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 新闻表 服务实现类
 * </p>
 *
 * @author author
 * @since 2024-03-11
 */
@Service
public class GeConVenueServiceImpl extends ServiceImpl<GeConVenueDao, GeConVenue> implements GeConVenueService {

    @Autowired
    private GeConVenueDao geConVenueDao;

    @Override
    public void insert(GeConVenue geConVenue) {
        geConVenueDao.insert(geConVenue);
    }

    @Override
    public void updateEntity(GeConVenue geConVenue) {
        geConVenueDao.updateById(geConVenue);
    }

    @Override
    public void deleteById(int newId) {
        geConVenueDao.deleteById(newId);
    }

    @Override
    public List<GeConVenue> getAllNewsByValue(VenueQuery venueQuery) {
        return geConVenueDao.getAllNewsByValue(venueQuery);
    }

    @Override
    public List<GeConVenue> getAllNewsByValueNoContent(VenueQuery venueQuery) {
        return geConVenueDao.getAllNewsByValueNoContent(venueQuery);
    }

    @Override
    public GeConVenue queryById(Integer newId) {
        return geConVenueDao.queryById(newId);
    }

    @Override
    public CommonResult getVenueNums(String date) {
        DateTimeFormatter formatter =  DateTimeFormatter.ofPattern("yyyy-MM-dd");
        //不传，默认当天
        if(date==null||"".equals(date)){
            date = LocalDateTime.now().format(formatter);
        }
        List<VenueNumsVO> venueNums = geConVenueDao.getVenueNums(date);
        return CommonResult.success("查询成功",venueNums);
    }
}
